//
//  MessageTableViewCell.m
//  Civacrm
//
//  Created by zhk on 2017/2/8.
//  Copyright © 2017年 王桂敏. All rights reserved.
//

#import "MessageTableViewCell.h"

@implementation MessageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    return self;
    
}

- (void)setupView
{
    self.backgroundColor = [UIColor clearColor];
    
    self.bgView = [[UIView alloc]init];
    [self.contentView addSubview:self.bgView];
    self.bgView.backgroundColor = [UIColor whiteColor];
//    self.bgView.layer.masksToBounds = YES;
//    self.bgView.layer.cornerRadius = self.height / 5;
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(10);
        make.right.bottom.offset(-10);
    }];
    
    
//    self.bgImageView = [[UIImageView alloc]init];
//    [self.contentView addSubview:self.bgImageView];
//    self.bgImageView.image = Image(@"bg-frame");
//    self.bgImageView.backgroundColor = [UIColor clearColor];
//    [self.bgImageView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.left.offset(5);
//        make.right.offset(-5);
//        make.top.offset(5);
//        make.height.offset(30);
//    }];
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.backgroundColor = GlobalBlue;
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font = font(32);
    [self.bgView addSubview:self.titleLabel];
    [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.offset(0);
        make.size.mas_offset(CGSizeMake(kScreenWidth - 20, 30));
    }];
    
    self.timeLabel = [[UILabel alloc]init];
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    self.timeLabel.backgroundColor = [UIColor clearColor];
    self.timeLabel.textColor = [UIColor whiteColor];
    self.timeLabel.font = font(24);
    [self.titleLabel addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-15);
        make.centerY.equalTo(self.titleLabel);
    }];
    
    self.contentLabel = [[UILabel alloc]init];
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.textColor = ColorWithHexString(@"73a0ba");
    [self.bgView addSubview:self.contentLabel];
    self.contentLabel.font = font(26);
    [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.right.offset(-10);
        make.top.equalTo(self.titleLabel.mas_bottom);
        make.bottom.offset(-10);
    }];
}

- (void)takeDataForCellWithModel:(MessageModel *)model
{
    self.titleLabel.text = [NSString stringWithFormat:@"   %@",model.title];
    self.contentLabel.text = model.content;
    self.timeLabel.text = model.createDate;
}

@end
